<?php
session_start();
include("load-settings.php");

if(!isset($_SESSION['user']))
	header("Location: login.php");

$user = $_SESSION['user'];

$result = mysql_query("SELECT * FROM user WHERE id = $user");
$row = mysql_fetch_array($result);

if($row['type'] != 2)
	header("Location: home.php");

if(!isset($_GET['id']))
	header("Location: booster-applications.php");

$application = mysql_real_escape_string($_GET['id']);

mysql_query("UPDATE booster_application SET approved = 1 WHERE id = $application");

$result = mysql_query("SELECT * FROM booster_application WHERE id = $application") or die(mysql_error());
$row = mysql_fetch_array($result);

$result = mysql_query("SELECT * FROM user WHERE paypal = '".$row['email']."'") or die(mysql_error());
$row = mysql_fetch_array($result);

$pass = $row['password'];
$hash = crypt($pass);

mysql_query("UPDATE user SET type = 1, password = '$hash' WHERE id = ".$row['id']) or die(mysql_error());

header("Location: booster-applications.php");
?>